package com.nanhang.common.util.springboot;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
public class Result {
	private Integer code;
	private String message;
	private Map<String,Object> data = new HashMap<>();
	public static Result ok(){
		Result result = new Result();
		result.setCode(200);
		result.setMessage("操作成功");
		return result;
	}
	public static Result error(){
		Result result = new Result();
		result.setCode(500);
		result.setMessage("操作失败");
		return result;
	}
	public Result message(String message){
		this.setMessage(message);
		return this;
	}
	public Result code(Integer code){
		this.setCode(code);
		return this;
	}
	public Result data(String key, Object value){
		this.data.put(key,value);
		return this;
	}
	public Result data(Map<String,Object> map){
		this.setData(map);
		return this;
	}

}
